package com.sixth.controller;

import com.sixth.entity.Banner;
import com.sixth.entity.Head;
import com.sixth.entity.TableResult;
import com.sixth.service.BannerService;
import com.sixth.until.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: self-tui-education
 * @description:
 * @author: C
 * @create: 2022-04-21 15:53
 **/
@RestController
@RequestMapping("/home/banner")
public class BannerController {
    @Autowired
    private BannerService bannerService;

    //轮播导航查询功能
    @PostMapping("/getAllBanner/{pageNum}/{pageSize}")
    private TableResult selectAllTeacher(@PathVariable Integer pageNum, @PathVariable Integer pageSize, @RequestBody Banner banner) {
        return bannerService.selectAllHead(pageNum, pageSize, banner);
    }

    //添加和修改
    @PostMapping("/addBanner")
    public CommonResult addOrUpdateBanner(@RequestBody Banner banner) {
        System.out.println(banner);
        if (banner.getId()==null){
            return bannerService.addZone(banner);
        }else {
            return bannerService.UpdateZone(banner);
        }
    }


    //轮播导航删除功能
    @PostMapping("/deleteBanner")
    public CommonResult delete(@RequestBody Banner banner ) {
        return bannerService.deleteFindById(banner);
    }

    //轮播导航修改状态
    @PostMapping("/changeStatus/{id}/{isDisable}")
    public CommonResult updateStatus(@PathVariable String id, @PathVariable String isDisable) {
            return bannerService.changeStatus(id,isDisable);
        }


}